package com.windowes.weichang.subscribe;

import com.windowes.weichang.service.DemandService;
import com.windowes.weichang.utils.RedisPrefixUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/7/14 下午8:50
 * @description:
 *
 **/
@Component
@Slf4j
public class TaskHandleService {


    @Autowired
    DemandService demandService;


    public void handle(String message) {
        if (StringUtils.isEmpty(message)) {
            return;
        }

        if (!message.startsWith(RedisPrefixUtil.PREFIX)) {
            log.info("非系统消息不处理,message:{}", message);
            return;
        }
        //未预约订单超期
        if (message.contains(RedisPrefixUtil.APPOINT_PREFIX)) {
            String orderId = RedisPrefixUtil.messageToOrderId(message);
            demandService.notifyUnHandleDemand(orderId);
        }
    }
}
